//
//  StateFrame.m
//  uniquelove
//
//  Created by ibokan on 14-12-17.
//  Copyright (c) 2014年 ibokan. All rights reserved.
//

#import "StateFrame.h"
#import "StateModel.h"
#import "NSString+Extension.h"
@implementation StateFrame

-(void)setStateModel:(StateModel *)stateModel{
    _stateModel = stateModel;
    //间距
    CGFloat padding = 5;
    //屏幕宽度
    CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
    
    
    //时间的frame
    CGFloat timeH = 20;
    _timeF = CGRectMake(0, 0, screenW, timeH);
    
    //1.头像的frame
    CGFloat iconX = padding;
    CGFloat iconY = timeH +padding;
    CGFloat iconW = 50;
    CGFloat iconH = 50;
    _iconF = CGRectMake(iconX, iconY, iconW, iconH);
    
    //2.昵称的frame
    CGFloat nameX = padding * 2 + iconW;
    CGFloat nameY = iconY;
    CGFloat nameW = screenW - nameX - padding;
    CGFloat nameH = 30;
    _nameF = CGRectMake(nameX, nameY, nameW, nameH);
    
    //3.正文的frame
    CGFloat textX = nameX;
    CGFloat textY = CGRectGetMaxY(_nameF) + padding;
    CGFloat textW = nameW;
    CGFloat textH;
    // 文字计算的最大尺寸
    CGSize textMaxSize = CGSizeMake(200, MAXFLOAT);
    // 文字计算出来的真实尺寸
    CGSize textRealSize = [stateModel.text sizeWithFont:TextFont maxSize:textMaxSize];
    // 最终的真实尺寸
    textH = textRealSize.height;
    _textF = CGRectMake(textX, textY, textW, textH);
    
    //cell的高度
    _cellHeight = 3 * padding + nameH + textH + timeH;
}


@end
